var DeviceSound = function(container,playerID,type) {
	this.container = container;
	this.playerID = playerID;
	this.applianceType = "";
	this.soundFile = "";
	switch (type)
	{
		case "fan":
			this.applianceType = 'fan';
			this.soundFile = "";
			break;
		case "washerdryer":
			this.applianceType = 'washerdryer';
			this.soundFile = "";
			break;
		case "dishwasher":
			this.applianceType = 'dishwasher';
			this.soundFile = "dishwasher.ogg";
			break;
		case "blowdryer":
			this.applianceType = 'blowdryer';
			this.soundFile = "blowdryer.ogg";
		default:
			break;
	}
	this.container.innerHTML = 
		this.container.innerHTML + "<audio id=\"" + this.playerID + "\" src=\"" + this.soundFile + "\" preload=\"auto\" type=\"audio/ogg\" autobuffer loop></audio>";
	this.audioElt = document.getElementById(this.playerID);
	this.audioElt.setAttribute('type', 'audio/ogg');
	
	this.decrementVolume = function() {
		if (this.audioElt.volume > .5)
		{
			setTimeout(function(thisObj) { 
				thisObj.audioElt.volume = thisObj.audioElt.volume-.05;
				thisObj.decrementVolume();
			},40,this);
		}
	}
	
	this.turnOn = function() {
		this.audioElt.volume = 1;
		this.audioElt.play();
		setTimeout(function(thisObj) { thisObj.decrementVolume(); }, 5000, this);
	};
	
	this.turnOff = function() {
		this.audioElt.pause();
	};
}


